﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using XBoshiGFS.reports;
using XBoshi.SecurityCommon;

namespace XBoshiGFS.forms
{
    public partial class MainMDIParent : Form
    {

        public static String currentUserCode = null;
        public static  StationSet station = null;
        public static LicenseClass license = null; 




        private int childFormNumber = 0;
        MainForm mainform = new MainForm();

        public MainMDIParent()
        {
            InitializeComponent();
           LoginForm login = new LoginForm();
           login.ShowDialog();
           if (login.DialogResult == DialogResult.OK )
           {

               mainform.MdiParent = this;
           }
           else {
               Application.Exit();
               this.Close();
           }
           
            
        }

        private void ShowNewForm(object sender, EventArgs e)
        {
            Form childForm = new Form();
            childForm.MdiParent = this;
            childForm.Text = "Window " + childFormNumber++;
            childForm.Show();
        }

        private void OpenFile(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            openFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = openFileDialog.FileName;
            }
        }

        private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            saveFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = saveFileDialog.FileName;
            }
        }

        private void ExitToolsStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void CutToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void CopyToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void PasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void ToolBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            toolStrip.Visible = toolBarToolStripMenuItem.Checked;
        }

        private void StatusBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            statusStrip.Visible = statusBarToolStripMenuItem.Checked;
        }

        private void CascadeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.Cascade);
        }

        private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileVertical);
        }

        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.ArrangeIcons);
        }

        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form childForm in MdiChildren)
            {
                childForm.Close();
            }
        }

        private void menuStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {

        }

        private void MainMDIParent_Load(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Normal ;
            mainform = new MainForm();
            mainform.MdiParent = this;
            mainform.Show();
            this.WindowState = FormWindowState.Maximized;
            
            //mainform.WindowState = FormWindowState.Minimized;
            //mainform.WindowState = FormWindowState.Maximized;
        }

        private void MENU_MainPage_Click(object sender, EventArgs e)
        {

            mainform.Close();  

            mainform = new MainForm();
            mainform.MdiParent = this;
            MENU_MainPage.Checked = true;
            mainform.Show();
            mainform.WindowState = FormWindowState.Minimized; 
            mainform.WindowState =  FormWindowState.Maximized ;  


        }

        private void MNU_Exit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AboutBox a = new AboutBox();
            a.ShowDialog();
        }

        private void MNU_RePassWord_Click(object sender, EventArgs e)
        {
            RePassWordForm frm = new RePassWordForm();
            frm.ShowDialog();
        }

        private void ImporHisDate_Click(object sender, EventArgs e)
        {
            ImportHisDataFrom frm = new ImportHisDataFrom();
            frm.ShowDialog ();
        }

        private void MNU_PriceMaintain_Click(object sender, EventArgs e)
        {
           
            PriceMaintainForm frm=new PriceMaintainForm() ;
           // frm.MdiParent = this;
            frm.station =MainMDIParent.station ;
            frm.BindData();
            frm.ShowDialog();
        }

        private void MNU_PeoplMaintain_Click(object sender, EventArgs e)
        {
            PeopleForm pm = new PeopleForm();
   //         pm.MdiParent = this;
            pm.ShowDialog(); 
        }

        private void MNU_PeopleListPrint_Click(object sender, EventArgs e)
        {
            WaterBillReportForm rpm = new WaterBillReportForm();
            rpm.MdiParent = this;
            
            rpm.Show();
            rpm.WindowState = FormWindowState.Maximized; 
        }

        private void toolStripMenuItem5_Click(object sender, EventArgs e)
        {
            WaterSeasonForm wsm = new WaterSeasonForm();
            wsm.Show();
        }

        private void MNU_WaterBillPubish_Click(object sender, EventArgs e)
        {
            WaterBillPublishReportForm rpm = new WaterBillPublishReportForm();
            rpm.MdiParent = this;

            rpm.Show();
            rpm.WindowState = FormWindowState.Maximized; 
        }

        private void MNU_WaterBillPrint_Click(object sender, EventArgs e)
        {
            WaterUsageBillsForm rpm = new WaterUsageBillsForm();
            rpm.MdiParent = this;

            rpm.Show();
            rpm.WindowState = FormWindowState.Maximized; 
        }

        private void MNU_WaterUsageInput_Click(object sender, EventArgs e)
        {
            WaterUsageInputForm rpm = new WaterUsageInputForm();
            rpm.MdiParent = this;
            rpm.Show();
            rpm.WindowState = FormWindowState.Maximized; 

        }

        private void MNU_WaterPriceQuery_Click(object sender, EventArgs e)
        {

            StationSet station = MainMDIParent.station;
            
            PriceMaintainForm frm = new PriceMaintainForm(station ,true );
            //frm.MdiParent = this;
            
            frm.ShowDialog();
        }

        private void MNU_PeopleQuery_Click(object sender, EventArgs e)
        {
            PeopleInforQueryForm piq = new PeopleInforQueryForm();
            piq.MdiParent = this;
            piq.Show(); 
        }

        private void MNU_BillsRePrint_Click(object sender, EventArgs e)
        {
            //发票补打

            WaterUsageBillsRePrintForm rpm = new WaterUsageBillsRePrintForm();
            rpm.MdiParent = this;
            rpm.Show();
            rpm.WindowState = FormWindowState.Maximized; 

        }

        private void MNU_DateBack_Click(object sender, EventArgs e)
        {
            BackUpAndRestorForm brform = new BackUpAndRestorForm();
            brform.ShowDialog(); ; 
        }

        private void MNU_DateRestor_Click(object sender, EventArgs e)
        {
            BackUpAndRestorForm brform = new BackUpAndRestorForm();
            brform.SetTabPage(1);
            brform.ShowDialog(); ; 
        }

        private void MNU_WaterUsageQuery_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor; 
            WaterUsageInforQueryForm uinfo = new WaterUsageInforQueryForm();
            uinfo.MdiParent = this;
            uinfo.Show();
            Cursor = Cursors.Default;
        }

        private void MNU_GroupMaintain_Click(object sender, EventArgs e)
        {
            GroupForm gm = new GroupForm();
            gm.ShowDialog(); 
        }

        private void MNU_VallageMaintain_Click(object sender, EventArgs e)
        {
            VillageForm gm = new VillageForm();
            gm.ShowDialog(); 
        }

        private void MNU_WaterCourseMaintain_Click(object sender, EventArgs e)
        {
            WaterCourseForm gm = new WaterCourseForm();
            gm.ShowDialog(); 
        }

        private void MNU_SegmentCoursorMaintain_Click(object sender, EventArgs e)
        {
            SegmentForm gm = new SegmentForm();
            gm.ShowDialog(); 
        }

        private void MNU_StationMaintain_Click(object sender, EventArgs e)
        {
            StationForm gm = new StationForm();
            gm.ShowDialog(); 
        }

        private void MNU_init_Click(object sender, EventArgs e)
        {
            




        }

        private void MNU_BILLTEST_Click(object sender, EventArgs e)
        {
            WaterUsageBillsTestForm wf = new WaterUsageBillsTestForm();
            wf.ShowDialog(); 
        }

        private void 打印设置ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PageSetUp form = new PageSetUp();
            form.ShowDialog ();
        }

     


 
    }
}
